//
//  tianjianOAAppDelegate.m
//  tianjianOA
//
//  Created by tianhe xie on 12-3-18.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "tianjianOAAppDelegate.h"
//#import "tianjianOAViewController.h"
#import "personalOfficeController.h"
#import "daliryOfficeController.h"
#import "adminManageController.h"
#import "publicInfoController.h"
#import "moreController.h"


@implementation tianjianOAAppDelegate

@synthesize window;
//@synthesize viewController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    //[self.window addSubview:viewController.view];
	[self initTabBar];
    [self.window makeKeyAndVisible];

    return YES;
}


//初始化tab bar
-(void)initTabBar
{

	tabBarController = [[UITabBarController alloc] init];
	//个人办公
	personalOfficeController *personal = [[personalOfficeController alloc] init];
	UINavigationController *personalNav = [[UINavigationController alloc] initWithRootViewController:personal];
	[personal release];
	
	//日常办公
	daliryOfficeController *daliry = [[daliryOfficeController alloc] init];
	UINavigationController *daliryNav = [[UINavigationController alloc] initWithRootViewController:daliry];
	[daliry release];
	
	//行政管理
	adminManageController *admin = [[adminManageController alloc] init];
	UINavigationController *adminNav = [[UINavigationController alloc] initWithRootViewController:admin];
	[admin release];
	
	//公共信息
	publicInfoController *Info = [[publicInfoController alloc] init];
	UINavigationController *InfoNav = [[UINavigationController alloc] initWithRootViewController:Info];
	[Info release];
	
	//更多
	moreController *more = [[moreController alloc] init];
	UINavigationController *moreNav = [[UINavigationController alloc] initWithRootViewController:more];
	[more release];
	
	tabBarController.viewControllers = [NSArray arrayWithObjects:personalNav,
										daliryNav,
										adminNav,
										InfoNav,
										moreNav,nil
										];
	
	tabBarController.delegate = self;
	
	UIImage* anImage0 = [UIImage imageNamed:@"tab0.png"];
	UITabBarItem* theItem0 = [[UITabBarItem alloc] initWithTitle:@"个人办公" image:anImage0 tag:0];	
	personalNav.tabBarItem = theItem0;
	[theItem0 release];
	
	UIImage* anImage1 = [UIImage imageNamed:@"tab1.png"];
	UITabBarItem* theItem1 = [[UITabBarItem alloc] initWithTitle:@"日常办公" image:anImage1 tag:1];	
	daliryNav.tabBarItem = theItem1;
	[theItem1 release];
	
	UIImage* anImage2 = [UIImage imageNamed:@"tab2.png"];
	UITabBarItem* theItem2 = [[UITabBarItem alloc] initWithTitle:@"行政管理" image:anImage2 tag:2];	
	adminNav.tabBarItem = theItem2;
	[theItem2 release];
	
	UIImage* anImage3 = [UIImage imageNamed:@"tab3.png"];
	UITabBarItem* theItem3 = [[UITabBarItem alloc] initWithTitle:@"公共信息" image:anImage3 tag:3];	
	InfoNav.tabBarItem = theItem3;
	[theItem3 release];
	
	UIImage* anImage4 = [UIImage imageNamed:@"tab4.png"];
	UITabBarItem* theItem4 = [[UITabBarItem alloc] initWithTitle:@"更多" image:anImage4 tag:4];	
	moreNav.tabBarItem = theItem4;
	[theItem4 release];
	
	[personalNav release];
	[daliryNav release];
	[adminNav release];
	[InfoNav release];
	[moreNav release];
	
	//[tabBarController.]
	[window addSubview:tabBarController.view];
	
	
	
	
	
	

}

- (void)applicationWillResignActive:(UIApplication *)application {
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
     */
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    /*
     Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
     */
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}


- (void)applicationWillTerminate:(UIApplication *)application {
    /*
     Called when the application is about to terminate.
     See also applicationDidEnterBackground:.
     */
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    /*
     Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
     */
}


- (void)dealloc {
    //[viewController release];
	[tabBarController release];
    [window release];
    [super dealloc];
}


@end
